<?php
define('IN_QY',true);
session_start();
require("include/common.inc.php");
require('include/functions.php');
require_once("include/config.php");
require_once("include/httpUtil.php");
//
$infoid=trim($_GET['fid']);
$uid=trim($_GET['uid']);
if($uid==""||$infoid==""){
    $arr = array('error'=>'为空','msg'=>'false');
    echo json_encode($arr);
    exit;
}

$sql = "select sum(totprice+expresstri+taxpri-yhqmoney) as tot from tbl_taorder where uid='".$_GET['uid']."' and is_pay=3 AND orderid='".$infoid."' ";
$query = mysql_query($sql);
$rows = mysql_fetch_array($query);
$temtot = round($rows['tot'], 2);

$sql1 = "select max(id) as maxid,orderid,addtime from tbl_taorder where uid='".$_GET['uid']."' and is_pay=3 ";
$query1 = mysql_query($sql1);
$row1 = mysql_fetch_array($query1);

header("Content-type: text/html; charset=utf-8"); 
$app_id = "b6b437fa-c5cf-4e88-801b-c51696582283";
$app_secret = "1e08c791-1384-424e-81ae-5a31f1333add";
$amount =  (int)($temtot*100);//支付总价
$title = ("APP海淘订单-").$temtot;
$out_trade_no = $infoid;//订单号，需要保证唯一性
//1.生成sign
$sign = md5($app_id . $title . $amount . $out_trade_no . $app_secret);
//支付吊起结束

?>
<!DOCTYPE html>
<html>
<meta name="viewport" content="width=device-width,initial-scale=1.0,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no"> 
<head>
	<meta charset="utf-8">
	<meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
	<title>支付订单</title>	
	<link rel="stylesheet" href="/svn/css/style.css" type="text/css"/>	
	<script type="text/javascript" src="/svn/js/jquery-1.8.2.min.js" ></script>	
</head>	
<body>
<!--头部  star-->
<header style="color:#fff">
<span>海淘订单支付</span>
</header>
<!--头部 end-->
<!--内容 star-->
<div class="contaniner fixed-cont">
	<div class="pay_img"><img src="/svn/images/pay.jpg"></div> 
    <div class="payTime">
        <li><strong>¥ &nbsp;<?=$temtot?></strong></li>
        <li>订单号:<?=$infoid?></li>
    </div> 
    <!--支付 star-->
	<div class="pay">
		<div class="show">
		    <!--支付 star
			<li><label><img src="/svn/images/weixin.png" >微信支付<input name="Fruit" type="radio" value="" checked/><span></span></label> </li>
			-->			
    		<li><label><img src="/svn/images/zhifubao.png" >支付宝<input name="Fruit" id="test" type="radio" value="" /><span></span></label> </li>
		</div>
	</div> 
    <!--支付 end-->  
</div>
<script id='spay-script' src='https://jspay.beecloud.cn/1/pay/jsbutton/returnscripts?appId=b6b437fa-c5cf-4e88-801b-c51696582283'></script>
<script>
    //3. 需要发起支付时(示例中绑定在一个按钮的click事件中),调用BC.click方法
    document.getElementById("test").onclick = function() {
        asyncPay();
    };
    function bcPay() {
        BC.click({
			 "amount": <?php echo $amount; ?>,
            "title": "<?php echo $title; ?>",
			 "analysis": {"ip":"<?php echo $_SERVER['REMOTE_ADDR']; ?>"},
           
            "out_trade_no": "<?php echo $out_trade_no;?>", //唯一订单号
            "sign" : "<?php echo $sign;?>",
			"instant_channel":"ali",
            /**
             * optional 为自定义参数对象，目前只支持基本类型的key ＝》 value, 不支持嵌套对象；
             * 回调时如果有optional则会传递给webhook地址，webhook的使用请查阅文档
             */
            "optional": {"test": "willreturn"},
			"return_url":"https://xcx.goodshare.com.cn/taodzfbhd.php",		
		
        });
    }
    // 这里不直接调用BC.click的原因是防止用户点击过快，BC的JS还没加载完成就点击了支付按钮。
    // 实际使用过程中，如果用户不可能在页面加载过程中立刻点击支付按钮，就没有必要利用asyncPay的方式，而是可以直接调用BC.click。
    function asyncPay() {
        if (typeof BC == "undefined") {
            if (document.addEventListener) { // 大部分浏览器
                document.addEventListener('beecloud:onready', bcPay, false);
            } else if (document.attachEvent) { // 兼容IE 11之前的版本
                document.attachEvent('beecloud:onready', bcPay);
            }
        } else {
            bcPay();
        }
    }
</script>
<!--内容    
<div class="book-recovery-bot2" id="footer">
	<a href="#"><div class="payBottom">
    	<li class="textfr">确认支付:</li>
        <li class="textfl"><span>¥56.00</span></li>
    </div>
	</a>
</div> 
 end-->
</body>
</html>